home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Animation How-To
/
Animation How-to CD.iso
/
PLY
/
CHAPTER8
/
FAN
/
FAN.BAS
next >
Wrap
BASIC Source File
|
1994-01-01
|
2KB
|
115 lines
' FAN.BAS
DECLARE SUB Branch (x1, y1, height, level)
DECLARE FUNCTION Ang (x1, y1, x2, y2)
COMMON SHARED rad, theta, scale, angle, k, twig
SCREEN 12
WINDOW (-64, -10)-(64, 86)
angle = 10
twig = 10
frame = 0
OPEN "anim.bat" FOR OUTPUT AS #2
FOR sc = .6 TO .86 STEP .01
frame = frame + 1
inc$ = "fan" + RIGHT$("00" + LTRIM$(STR$(frame)), 2) + ".inc"
tga$ = "fan" + RIGHT$("00" + LTRIM$(STR$(frame)), 2) + ".tga"
PRINT #2, "echo include "; CHR$(34); inc$; CHR$(34); " > anim.inc"
PRINT #2, "\ply\polyray fan.pi -o "; tga$
OPEN inc$ FOR OUTPUT AS #1
scale = sc ^ .5
rad = 3.14159 / 180
height = 10
twig = twig - .2
angle = angle + .5
level = 8
x1 = 0
y1 = 0
x2 = 0
y2 = y1 + height
LINE (x1, y1)-(x2, y2)
PRINT #1, "object {"
PRINT #1, USING " object {cone <###.###,###.###,###.###>,###.###,<###.###,###.###,###.###>,###.### matte__white }"; x1, y1, 0, height * scale / twig, x2, y2, 0, height * scale * scale / twig
' Left Hand Sides
theta = Ang(x1, y1, x2, y2)
theta = theta + angle
levelsave = level
CALL Branch(x2, y2, scale * height, level)
level = levelsave
' Right Hand Sides
theta = Ang(x1, y1, x2, y2)
theta = theta - angle
CALL Branch(x2, y2, scale * height, level)
FOR w = 1 TO 100000: NEXT w
CLS
PRINT #1, "}"
CLOSE #1
NEXT sc
CLOSE #2
FUNCTION Ang (x1, y1, x2, y2)
' returns the angle of a vector with respect to the x-axis
IF ((x2 - x1) = 0) THEN
IF (y2 > y1) THEN
theta = 90
ELSE
theta = 270
END IF
ELSE
theta = ATN((y2 - y1) / (x2 - x1)) / rad
END IF
IF (x1 > x2) THEN theta = theta + 180
Ang = theta
END FUNCTION
SUB Branch (x1, y1, height, level)
x = x1
y = y1
x = x + height * COS(theta * rad)
y = y + height * SIN(theta * rad)
x2 = x
y2 = y
level = level - 1
LINE (x1, y1)-(x2, y2), 15
PRINT #1, USING " + object {cone <###.###,###.###,###.###>,###.###,<###.###,###.###,###.###>,###.### matte__white }"; x1, y1, 0, height * scale / twig, x2, y2, 0, height * scale * scale / twig
IF (level > 0) THEN
' Left Hand Sides
theta = Ang(x1, y1, x2, y2)
theta = theta + angle
levelsave = level
CALL Branch(x2, y2, scale * height, level)
level = levelsave
' Right Hand Sides
theta = Ang(x1, y1, x2, y2)
theta = theta - angle
levelsave = level
CALL Branch(x2, y2, scale * height, level)
level = levelsave
END IF
END SUB